//
//  ACCacheConfiguration.m
//  ACCache_Example
//
//  Created by autohome on 2021/8/10.
//  Copyright © 2021 CaiXiang. All rights reserved.
//

#import "ACCacheConfiguration.h"

static ACCacheConfiguration *_cacheConfiguration;
static const NSInteger kDefaultCacheEffectiveCacheTime = 60 * 60 * 24 * 7; // 1 week

@implementation ACCacheConfiguration

+ (ACCacheConfiguration *)defaultCacheConfig {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _cacheConfiguration = [ACCacheConfiguration new];
    });
    return _cacheConfiguration;
}

- (instancetype)init {
    if (self = [super init]) {
        _cacheType = ACCachePolicyMemory;
        _effectiveCacheTime = kDefaultCacheEffectiveCacheTime;
    }
    return self;
}

- (id)copyWithZone:(NSZone *)zone {
    ACCacheConfiguration *config = [[[self class] allocWithZone:zone] init];
    config.effectiveCacheTime = self.effectiveCacheTime;
    config.cacheType = self.cacheType;
    config.name = self.name;
    config.memoryCostLimit = self.memoryCostLimit;
    config.memoryCountLimit = self.memoryCountLimit;
    return config;
}

@end
